package templet

import "encoding/json"

// Path: dialog.go 根据用户的内容进行回复

type Dialog struct {
	Content string
}

type content struct {
	Text string `json:"text"`
}

func (d *Dialog) Reply() string {
	if d.GetContent() == "你好" {
		return "你好啊"
	} else if d.GetContent() == "你是谁" {
		return "我是机器人"
	} else if d.GetContent() == "你叫什么" {
		return "我叫小明"
	}
	return "Dialog Reply"
}

func (d *Dialog) GetContent() string {
	var c content
	err := json.Unmarshal([]byte(d.Content), &c)
	if err != nil {
		return ""
	}
	return c.Text
}
